package com.zx.task.manager.enums;

import lombok.Getter;

/**
 * <p>
 * description: 任务严重程度枚举定义 <br>
 * create: 2025-10-13 20:15
 * </p>
 *
 * @author zhou  xun
 */
@Getter
public enum TaskSeverityEnum {
    FATAL(1, "致命"),
    SERIOUS(2, "严重"),
    GENERAL(3, "一般"),
    MINOR(4, "轻微");

    /**
     * code
     */
    private final Integer code;
    /**
     * 说明
     */
    private final String desc;

    TaskSeverityEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static TaskSeverityEnum getEnumByDesc(String desc) {
        for (TaskSeverityEnum value : values()) {
            if (value.desc.equals(desc)) {
                return value;
            }
        }
        return null;
    }

    public static TaskSeverityEnum getEnumByCode(Integer code) {
        for (TaskSeverityEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }
}